/*
 * CalendarTrans.h
 *
 *  Created on: 2010-4-5
 *      Author: Administrator
 */

#ifndef CALENDARTRANS_H_
#define CALENDARTRANS_H_
#include "symbian_macro.h"

struct MyChineseDate
	{
	TInt iCycle;
	TInt iYear;
	TInt iMonth;
	TBool iLeapMonth;
	TInt iDay;

	inline void init(int* array) {
		iCycle = array[0];
		iYear = array[1];
		iMonth = array[2];
		iLeapMonth = array[3] != 0;
		iDay = array[4];
	}

	inline void export_(int* array) {
		array[0] = iCycle;
		array[1] = iYear;
		array[2] = iMonth;
		array[3] = iLeapMonth ? 1 : 0;
		array[4] = iDay;
	}

	IMPORT_C TInt operator-(const MyChineseDate& bDate) const;
	};
struct MyDate
	{
	TInt iYear;
	TInt iMonth;
	TInt iDay;

	inline void init(int* array) {
		iYear = array[0];
		iMonth = array[1];
		iDay = array[2];
	}

	inline void export_(int* array) {
		array[0] = iYear;
		array[1] = iMonth;
		array[2] = iDay;
	}

	IMPORT_C TInt operator-(const MyDate& bDate) const;
	};
struct MyCalendarTransNode
	{
	MyDate iDate;
	MyChineseDate iChineseDate;
	TInt iCount;

private:
	static TBool _GetItem(MyCalendarTransNode& aNode, TInt idx);
	static TInt _GetCalendarTransTableLen();
	static TInt64 _GetCalendarTransTable(TInt idx);
friend class MyChineseCalendarConverter;
	};

class MyChineseCalendarConverter
	{
public:
	IMPORT_C static TBool DateTimeToChineseL(MyDate aDateTime, MyChineseDate& aChineseDate);
	IMPORT_C static TBool ChineseToDateTimeL(MyChineseDate aChineseDate, MyDate& aDateTime);
	IMPORT_C static void DateRange(MyDate& aLower, MyDate& aUpper);
	IMPORT_C static void DateRange(MyChineseDate& aLower, MyChineseDate& aUpper);
	};

#endif /* CALENDARTRANS_H_ */
